<%--
  Created by IntelliJ IDEA.
  User: Mankind
  Date: 2017/7/12
  Time: 15:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>SSM练手项目</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/login.css">
    <link rel="stylesheet" href="css/bootstrapValidator.min.css">
</head>
<body>
<div id="page">
    <img src="image/bg7.jpg" alt="">
    <div class="overlay"></div>
</div>
<div class="container">
    <div class="container-content">
        <div id="register" class="row">
            <div class="col-md-4 col-md-push-4">
                <div class="form-wrap">
                    <div class="tab">
                        <div class="tab-content">
                            <div class="tab-content-inner active" >
                                <h3 class="cursive-font text-center">用户注册</h3>
                                <form action="user/register" class="form-horizontal" id="register-form" method="post">
                                    <div class="form-group">
                                        <label for="account" class="control-label col-md-4">账&ensp;号</label>
                                        <div class="col-md-8 ">
                                            <input type="text"  class="form-control"  placeholder="账号" name="userAccount" id="account">
                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <label  class="control-label col-md-4">密&ensp;码</label>
                                        <div class="col-md-8">
                                            <input type="password"  class="form-control"  placeholder="请输入密码" name="userPassword" >
                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <label  class="control-label col-md-4">确认密码</label>
                                        <div class="col-md-8">
                                            <input type="password"  class="form-control"  placeholder="请再次输入密码" name="confirmPassword">
                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <label class="control-label col-md-4">昵&ensp;称</label>
                                        <div class="col-md-8">
                                            <input type="text"  class="form-control"  placeholder="请输入昵称" name="userName" >
                                        </div>
                                    </div>

                                    <div class="row form-group button-group">
                                        <div class="col-md-6">
                                            <a type="button" class="btn btn-primary btn-block" href="index.html">返回</a>
                                        </div>
                                        <div class="col-md-6">
                                            <input type="submit" class="btn btn-primary btn-block" value="下一步" id="next"/>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<input type="hidden" name="action">
<script src="js/jquery-3.0.0.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrapValidator.min.js"></script>
<script src="js/language/zh_CN.js"></script>
<script>
    $(function(){
        var x=$('#register-form').bootstrapValidator({
            message: 'This value is not valid',
            fields:{
                userAccount:{
                    validators:{
                        notEmpty:{
                            message: '账号不能为空'
                        },
                        remote:{
                            url:'user/accountCheck',
                            message: '用户已存在',
                            delay :  5000,
                            type: 'POST',
                            dataType: 'json'
                        }
                    }
                },
                userPassword:{
                    validators:{
                        notEmpty:{
                            message: '密码不能为空'
                        }
                    }
                },
                confirmPassword:{
                    validators:{
                        notEmpty:{
                            message: '密码不能为空'
                        },
                        identical:{
                            field:'userPassword',
                            message:'前后密码不一致'
                        }
                    }
                },
                userName:{
                    validators:{
                        notEmpty:{
                            message: '用户名不能为空'
                        }
                    }
                }
            }
        });
        $("#next").click(function(e){
             $('#register-form').bootstrapValidator('validate');
            var bootstrapValidator = $("#register-form").data('bootstrapValidator');
            if(bootstrapValidator.isValid()) {
                bootstrapValidator.defaultSubmit();
        }
        });
        $("input[name='action']").click(function(){
            alert("sb2");
            $('#register-form').submit();
        });
    });
</script>
</body>
</html>
